/* clock em Hz */
#define F_CPU 16000000UL

#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

#include "atm168/serial.h"

void main_init(void) {

  serial_init((F_CPU/SERIAL_BAUD/16)-1);
  /* set PC5 to output */
  DDRC |= 1 << PC5;
  PORTC &= ~(1 << PC5);
  _delay_ms(250);

}

int main(void) {

  //char msg[10];
  char* msg_sec = "Oi2\n";
  int ctr=0;

  main_init();
  /* Enable Interrupts */
  sei();

  while(1) {
    PORTC |= 1 << PC5;
    while (msg_sec[ctr]!='\0') {
      serial_transmit(msg_sec[ctr++]);
    }
    ctr = 0;
    PORTC &= ~(1 << PC5);
    _delay_ms(1000);
/*     if (serial_rx==1) { */
/*       PORTC |= 1 << PC5; */
/*       serial_read_buffer(msg); */
/*       serial_transmit(msg); */
/*       _delay_ms(100); */
/*       PORTC &= ~(1 << PC5); */
/*     } */
  }

  return 0;

}
